#include <GA\operations\mutation\Mutator.hpp>
#include <cstdlib>
#include <ctime>

unitraf::Mutator::Mutator(void)
{
}

unitraf::Mutator::~Mutator(void)
{
}


unitraf::Mutator::Mutator(double prob)
{
	srand( (unsigned)time(0) );
	_prob = prob;
}


void unitraf::Mutator::mutate( BinaryString *BS )
{
	for ( size_t i = 0; i < BS->getLength( ); ++i )
	{
		if ( rand( ) % 100 < (int)(_prob * 100)  )
		{
			BS->flipBit( i );
		}
	}
}
